import { defineConfig } from 'vite'
import createPlugins from './vite/plugins'
import { URL, fileURLToPath } from 'node:url';

// https://vitejs.dev/config/
export default defineConfig(()=>{
  return {
    resolve: {
      alias: {
        '~': fileURLToPath(new URL('./', import.meta.url)),
        '@': fileURLToPath(new URL('./src', import.meta.url)),
        '@pv': fileURLToPath(new URL('./packages/primevue/src', import.meta.url)),
        vue: 'vue/dist/vue.esm-bundler.js'
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "./src/assets/scss/global.scss" as *;`
        }
      },
      modules:{ //是对css模块化的默认行为进行覆盖

      }
    },
    // optimizeDeps:{
    //   include: ['@webcoder49/code-input']
    // },
    plugins: createPlugins(),
    build: {
      manifest: 'manifest-admin.json',
      reportCompressedSize: false,
      sourcemap: false,
      commonjsOptions: {
        ignoreTryCatch: false
      },
      rollupOptions: {
        output: {
          // manualChunks(id) {
          //   if (id.includes('node_modules')) {
          //     if (id.includes('vue3-sfc-loader')) {
          //       return 'vue3-sfc-loader';
          //     } else if (id.includes('wang-editor')) {
          //       return 'wang-editor';
          //     } else if (id.includes('json-editor-vue')) {
          //       return 'json-editor-vue';
          //     } else if (id.includes('@wangeditor')) {
          //       return 'wangeditor';
          //     } else if (id.includes('xgplayer')) {
          //       return 'xgplayer';
          //     }
          //     return 'vendor';
          //   }
          // }
        }
      }
    }
    // ,
    // esbuild: {
    //   drop: configEnv.command === 'build' ? ['console', 'debugger'] : []
    // }
  }
})
